package com.lzj.myapplication;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.View;
import android.widget.Toast;

import com.lzj.myapplication.bean.LunBo;

import java.util.HashMap;

public class MainActivity extends AppCompatActivity {


//    private String url = HttpUtil.GET_SERIAL_ROTATE;

    private String url  = "http://app.mabaotoutiao.com/mommy/pic/carouselFigure.do";

    private HashMap<String , Object> params = new HashMap<>();
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        //测试提交数据
        findViewById(R.id.text).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                HttpHelper.getInstance().get(url, params, new HttpCallback<LunBo>() {
                    @Override
                    public void onSuccess(LunBo lunbo) {
                        Log.i("lzj","size  "+lunbo.getData().getList().size());
                        Log.i("lzj","link  "+lunbo.getData().getList().get(0).getPic_url());
                        toast("请求成功"+lunbo.getData().getList().get(0).getPic_url());
                    }

                    @Override
                    public void onFailed(String string) {
                        toast("请求失败");
                    }
                });
            }
        });
    }

    public void toast(String string){
        Toast.makeText(this, string , Toast.LENGTH_SHORT).show();
    }
}
